package de.fuberlin.inf.alp4.ue2;

import java.util.concurrent.Callable;
//Idee: Klasse abstrakt, guard() abstrakt, mehrere Klassen, die es testweise erben
//dadurch Klasse bauen, die auf den guard der anderen Klasse warten kann.
public class MethodRequest implements Callable<MethodRequest> {
	private int g;
	private int prio;
	private int param;
	public boolean done = false;
	private int result;

	/**
	 * 
	 * @param p	usually a random value to be calculated
	 * @param prio the MethodRequest's Priority
	 */
	public MethodRequest(int p, int prio) {
		this.param = p;
		this.prio = prio;
	}

	public MethodRequest call() {
		Servant s = new Servant();
		this.result = s.m1(param);
		this.done = true;
		System.out.println("Call completed");
		return this;
	}

	
	public boolean guard() {
		this.g += 2;
		return (this.g%3 == 0);
	}

	public int getResult() {
		return this.result;
	}
	
	public int getPrio() {
		return this.prio;
	}
}
